Attribute VB_Name = "fullscreen"
Option Explicit

Public FullScreenHeight As Integer 'full screen height
Public FullScreenOnROM As Boolean 'choose whether to change resolution on rom load or not
Public FullScreenWidth As Integer 'full screen width
Public IsFullScreen As Boolean 'checks to see if it's in full screen mode
Public OriginalScreenHeight As Integer 'original screen height
Public OriginalScreenWidth As Integer 'original screen width
Public ScreenResolutionChange As Boolean 'choose whether to change resolution on fullscreen toggling

Public Const CCDEVICENAME = 32
Public Const CCFORMNAME = 32
Public Const CDS_FULLSCREEN = &H4
Public Const DM_PELSHEIGHT = &H100000
Public Const DM_PELSWIDTH = &H80000

Public Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Public Type DEVMODE
  dmDeviceName As String * CCDEVICENAME
  dmSpecVersion As Integer
  dmDriverVersion As Integer
  dmSize As Integer
  dmDriverExtra As Integer
  dmFields As Long
  dmOrientation As Integer
  dmPaperSize As Integer
  dmPaperLength As Integer
  dmPaperWidth As Integer
  dmScale As Integer
  dmCopies As Integer
  dmDefaultSource As Integer
  dmPrintQuality As Integer
  dmColor As Integer
  dmDuplex As Integer
  dmYResolution As Integer
  dmTTOption As Integer
  dmCollate As Integer
  dmFormName As String * CCFORMNAME
  dmUnusedPadding As Integer
  dmBitsPerPel As Integer
  dmPelsWidth As Long
  dmPelsHeight As Long
  dmDisplayFlags As Long
  dmDisplayFrequency As Long
End Type
Public Function IsScale(f As Integer) As Boolean

  Dim Z As Integer

  For Z% = 1 To 20
    If f% = Z% * 256 Then
      IsScale = True
      Exit Function
    End If
  Next Z%

  IsScale = False

End Function
Public Sub ChangeResolution(widthz As Integer, heightz As Integer)

  Dim DevM As DEVMODE

  Call EnumDisplaySettings(0, 0, DevM)

  DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
  DevM.dmPelsWidth = widthz
  DevM.dmPelsHeight = heightz

  Call ChangeDisplaySettings(DevM, CDS_FULLSCREEN)

End Sub

